const ADD='add';
const MINUS='minus';

const theReducer = (state=0,action)=>{
    switch (action.type) {
        case ADD:
            return state+1;
        case MINUS:
            return state-1;
        default:
            return state;
    }
};

function add() {
    return {type:ADD}
}

function minus() {
    return {type:MINUS}
}

function asyncAdd() {
    return dispatch=>{
        setTimeout(()=>{dispatch(add())},2000)
    }
}

export {theReducer,add,minus,asyncAdd}